# File: ally_soldier_shield_bash.gd
# 盾击训练：攻击有概率击晕敌人
extends TechnologyResource
class_name AllySoldierShieldBash

# 击晕概率和持续时间配置
var stun_chance = 0.2  # 20%击晕概率
var stun_duration = 1.0  # 击晕持续时间（秒）

func _init() -> void:
	super()
	# 界面显示用英文，后续可通过翻译系统替换
	display_name = "Shield Bash"
	description = "20% chance to stun target for 1s on attack"
	# 监听单位攻击事件
	GlobalSignal.gs_unit_attacked.connect(_on_unit_attack)

# 处理攻击事件回调
func _on_unit_attack(attacker: Unit, _target: Unit, _damage: int):
	# 仅处理友军步兵的攻击
	if attacker is AllySoldier and randf() <= stun_chance:
		# 施加击晕状态
		_target.apply_status("STUN", stun_duration)
